<?php

include_once("/var/www/html/new/com.inc.php");
$sql="select id,area from uu_land";
$GLOBALS['le']->query($sql);
while($row=$GLOBALS['le']->fetch_assoc()){
    $id = $row['id'];
    $citycode[$id]=$row;
}
// print_r($citycode);
foreach($citycode as $k => $v){
    // if($v['area']!=""){
        // $citycode[$k]['area']=substr($citycode[$k]['area'],0,-2);
    // }
    $area=explode('|',$citycode[$k]['area']);
    if($area[0]==1||$area[0]==2||$area[0]==3||$area[0]==4||$area[0]==32||$area[0]==33){
        $citycode[$k]['area']=$area[0].'|1|0';
    }
}

// print_r($citycode);
// exit;
foreach ($citycode as $key => $value){
    $s_code=$value['area'];
    $str="select n_code from pft_area_code_concat where s_code='$s_code' limit 1";
    $GLOBALS['le']->query($str);
    $GLOBALS['le']->fetch_assoc();
    $n_code=$GLOBALS['le']->f('n_code');
    $area1=explode('|',$s_code);
    $id = $key;
    // if($area1[0]==1||$area1[0]==2||$area1[0]==3||$area1[0]==4){
        // $BBB =$area1[0]."|";
        // $r=$o+1;
        // $str1="update uu_land set areacode='$n_code' where id=$id limit 1";        
    // }else{
      
        $str1="update uu_land set areacode='$n_code' where id=$id";  
    // }
    $res=$GLOBALS['le']->query($str1);
}
if($res){
        echo "更新成功";
    }
?>